import { getStream } from '../Core/connect'
import { Material } from '../Material/Material'
import { Object3D } from './Object3D'
import { Vector3 } from '../Math/Vector3'

export class Wall extends Object3D {
    readonly type: string
    height: number
    constructor(name: string, height: number = 1000) {
        super({name: name, type: 'Wall'})
        this.type = 'Wall'
        this.height = height
        this.setHeight(height)
        this.setPlace()
    }
    setHeight(height: number) {
        this.height = height
        const stream = getStream()
        const str = {function: 'setWallHeight', ids: `${this.uuid}`, height:`${this.height}`}
        stream.emitUIInteraction(str)
    }
    setMaterial(material: Material) {
        const stream = getStream()
        const str = {function: 'setWallColor', ids: `${this.uuid}`, Material:material }
        stream.emitUIInteraction(str)
    }
    // 设置墙纹理
    setWallMaterial(Material: Material, materialType: string) {
        const stream = getStream()
        const str = {function: 'makeWallMaterial', ids: `${this.uuid}`, Material:Material ,materialType: materialType}
        stream.emitUIInteraction(str)
    }
    replaceWallMaterial(Material: Material, materialType: string) {
        const stream = getStream()
        const str = {function: 'replaceWallMaterial', ids: `${this.uuid}`, Material:Material ,materialType: materialType}
        stream.emitUIInteraction(str)
    }
    buildWallByList(list:Array<Vector3>) {
        const stream = getStream()
        const str = {function: 'buildWallByList', ids: `${this.uuid}` , pointList: list}
        stream.emitUIInteraction(str)
    }
    replaceHeight(height: number) {
        this.height = height
        const stream = getStream()
        const str = {function: 'replaceWallHeight', ids: `${this.uuid}`, height:`${this.height}`}
        stream.emitUIInteraction(str)
    }
    setPlace() {
        const stream = getStream()
        const str = {function: 'setWallPlace', ids: `${this.uuid}`, name:`${this.name}`}
        stream.emitUIInteraction(str)
    }
    build() {
        const stream = getStream()
        const str = {function: 'buildWall', ids: `${this.uuid}`}
        stream.emitUIInteraction(str)
    }
}

